from likeshop_api_project.api.login_api import login_model
from likeshop_api_project.base.mybase import Tools


# 添加购物车
class add_shop_model(Tools):
    path = '/api/cart/add'

    def add_shop_action(self, item_id, goods_num, hd):
        add_shop_data = {
            "item_id": item_id,
            "goods_num": goods_num,
        }
        add_shop = self.huihua.post(url=self.hosturl+self.path, data=add_shop_data, headers=hd)
        return add_shop.json()


if __name__ == '__main__':
    import requests

    s = requests.session()
    reg = login_model(huihua=s)
    msg = reg.login_action(account="13356786546", password="rr98765", client=2)
    # print(msg)
    get_token = msg["data"]["token"]
    # print(get_token)
    hd = {"token": get_token}

    add_shop = add_shop_model(huihua=s)
    msg = add_shop.add_shop_action(item_id=9, goods_num=8, hd=hd)
    print(msg)